CMAKE_MINIMUM_REQUIRED(VERSION 2.8)

SET(TARGET_NAME HGE)
SET(DIR_WITH_SRC . include ZLIB BASS)
SET(IGNORED_LIBS "libci.lib")
ADD_DEFINITIONS(-DHGEDLL)
ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)

FIND_PACKAGE(DXSDK 8)
IF (DXSDK_FOUND)
	INCLUDE_DIRECTORIES(${DXSDK_INCLUDE_DIR})
	LINK_DIRECTORIES(${DXSDK_LIBRARY_DIR})
ELSE()
	MESSAGE(FATAL_ERROR "Unable to find DXSDK!")
ENDIF()

SET(SRC_FILES "")
FOREACH(DIR IN LISTS DIR_WITH_SRC)
	
	FILE(GLOB FILE_H ${DIR}/*.h)
	FILE(GLOB FILE_CPP ${DIR}/*.cpp ${DIR}/*.c)
	
	STRING(REPLACE "/" "\\\\" SRCGROUP ${DIR})

	IF (${SRCGROUP} STREQUAL .)
		SOURCE_GROUP("${TARGET_NAME}" FILES ${FILE_H} ${FILE_CPP})
	ELSE (${SRCGROUP} STREQUAL .)
		SOURCE_GROUP("${SRCGROUP}" FILES ${FILE_H} ${FILE_CPP})
	ENDIF()	
	
	SET(SRC_FILES ${SRC_FILES} ${FILE_H} ${FILE_CPP})
ENDFOREACH()

ADD_LIBRARY(${TARGET_NAME} SHARED ${SRC_FILES})
TARGET_LINK_LIBRARIES(${TARGET_NAME} d3d8 d3dx8 winmm)
SET_TARGET_PROPERTIES(${TARGET_NAME} PROPERTIES LINK_INTERFACE_LIBRARIES "")

SET_TARGET_PROPERTIES(${TARGET_NAME} 
	PROPERTIES 
	LINK_FLAGS /NODEFAULTLIB:\"${IGNORED_LIBS}\")
